package nrd;

import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;
import static org.junit.Assert.assertTrue;

/**
 * Verify ability of TheOrangeRobot to fire.
 * 
 * @author Nathan Dorman
 * 
 */
public class TestTheOrangeRobotFire extends RobotTestBed {

  boolean shotsFired = false;

  /**
   * Determine which robots to test.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,nrd.TheOrangeRobot";
  }

  /**
   * Determine if robot has fired by gun heat. Gun heat must be 0 to fire, so the gun must have
   * fired if the heat is over 0.
   * 
   * @param event details for the turn event
   */
  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    double heat = robot.getGunHeat();
    if (heat > 0) {
      shotsFired = true;
    }
  }

  /**
   * Tells the results of this battle.
   * 
   * @param event can be ignored
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    assertTrue("This Robot is able to shoot.", shotsFired);
  }
}
